package live.zs.mybatisboot.service.impl;

import live.zs.mybatisboot.entity.TbOrder;
import live.zs.mybatisboot.repo.TbOrderMapper;
import live.zs.mybatisboot.service.OrderService;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.SimpleSortSpecification;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author madison
 * @description
 * @date 2021/7/9 10:42
 */
@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private TbOrderMapper orderMapper;

    @Override
    public List<TbOrder> selectList() {
        return orderMapper.select(SelectDSLCompleter.allRowsOrderedBy(
                SimpleSortSpecification.of("create_time").descending()
        ));
    }

    @Override
    public int save(TbOrder order) {
        return orderMapper.insertSelective(order);
    }
}
